package org.meluk.billboard.jpa;


public enum GameType {

	SEA_BATTLE(0, "org.meluk.billboard.jpa.SEA_BATTLE"), CHESS(1,
			"org.meluk.billboard.jpa.CHESS");

	public static GameType fromId(final int id) {
		GameType[] types = GameType.values();
		for (GameType e : types) {
			if (e.id == id) {
				return e;
			}
		}

		throw new IllegalArgumentException(String.format(
				"GameType with id %s not found", id));
	}

	public static GameType fromLabel(final String label) {
		GameType[] types = GameType.values();
		for (GameType e : types) {
			if (e.label.equalsIgnoreCase(label)) {
				return e;
			}
		}

		throw new IllegalArgumentException(String.format(
				"GameType with label %s not found", label));
	}

	private final int id;

	private final String label;

	private GameType(final int id, final String label) {
		this.id = id;
		this.label = label;
	}

	public int getId() {
		return id;
	}

	public String getLabel() {
		return label;
	}

	@Override
	public String toString() {
		return id + ":" + label;
	}
}
